package Array;

import java.util.Scanner;
//数组的基本查找
public class GetIndex {
    public static void main(String[] args) {
        int[] arr = {10, 44, 23, 242, 111, 2, 0};

        int index=getindex(arr,10);
        System.out.println("该元素在数组中的索引为："+index);
    }

        private static int getindex ( int[] arr,int ele){
            for (int i = 0; i <arr.length; i++) {
                 if(ele==arr[i]){
                     return i;
                 }
            }
        return -1;
        }
    }
